//
//  MyDownLoadTableViewCell.m
//  Supervisor
//
//  Created by 小宇 on 2017/5/17.
//  Copyright © 2017年 北京怀教网络科技股份有限公司. All rights reserved.
//

#import "MyDownLoadTableViewCell.h"
@interface MyDownLoadTableViewCell ()
@property (weak, nonatomic) IBOutlet UIImageView *ImgView;
@property (weak, nonatomic) IBOutlet UILabel *titleNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *byUserNameLabel;
@property (weak, nonatomic) IBOutlet UILabel *upLoadTimeLabel;

@end
@implementation MyDownLoadTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

-(void)setdataWithDownLoadModel:(DownLoadModel *)model{
    self.ImgView.image = [self judgedimg:model.titleName];
    self.titleNameLabel.text = model.titleName;
    self.byUserNameLabel.text = model.byName;
    self.upLoadTimeLabel.text = model.upLoadTime;
}

- (UIImage *)judgedimg:(NSString *)filePath{
    UIImage *fileimg;
    NSArray *array = [filePath componentsSeparatedByString:@"."];
    if (array.count > 0) {
        NSString *filecategory = [array lastObject];
        NSString *filecategoryUp = [filecategory uppercaseString];//大写
        if([filecategoryUp isEqualToString:@"PNG"] || [filecategoryUp isEqualToString:@"PNG"] || [filecategoryUp isEqualToString:@"JPEG"] || [filecategoryUp isEqualToString:@"JPG"] || [filecategoryUp isEqualToString:@"BMP"] || [filecategoryUp isEqualToString:@"GIF"]){
            fileimg = [UIImage imageNamed:@"imgfile"];
        }else if ([filecategoryUp isEqualToString:@"DOC"] || [filecategoryUp isEqualToString:@"DOCX"] || [filecategoryUp isEqualToString:@"DOTX"] || [filecategoryUp isEqualToString:@"DOTM"]){
            fileimg = [UIImage imageNamed:@"wordfile"];
        }else if ([filecategoryUp isEqualToString:@"PDF"]){
            fileimg = [UIImage imageNamed:@"pfdfile"];
        }else if ([filecategoryUp isEqualToString:@"ZIP"] || [filecategoryUp isEqualToString:@"RAR"] || [filecategoryUp isEqualToString:@"7Z"]){
            fileimg = [UIImage imageNamed:@"zipfle"];
        }else if ([filecategoryUp isEqualToString:@"XLS"] || [filecategoryUp isEqualToString:@"XLSX"] || [filecategoryUp isEqualToString:@"XLTX"] || [filecategoryUp isEqualToString:@"XLSB"]){
            fileimg = [UIImage imageNamed:@"excelfile"];
        }else if ([filecategoryUp isEqualToString:@"PPT"] || [filecategoryUp isEqualToString:@"PPTX"] || [filecategoryUp isEqualToString:@"POTX"] || [filecategoryUp isEqualToString:@"POTM"]){
            fileimg = [UIImage imageNamed:@"pptfile"];
        }else if ([filecategoryUp isEqualToString:@"SETTING"]){
            fileimg = [UIImage imageNamed:@"setfile"];
        }else if ([filecategoryUp isEqualToString:@"INI"]){
            fileimg = [UIImage imageNamed:@"inifile"];
        }else if ([filecategoryUp isEqualToString:@"MP3"] || [filecategoryUp isEqualToString:@"MID"] || [filecategoryUp isEqualToString:@"WAV"] || [filecategoryUp isEqualToString:@"APE"] || [filecategoryUp isEqualToString:@"FLAC"]){
            fileimg = [UIImage imageNamed:@"voice"];
        }else if ([filecategoryUp isEqualToString:@"AVI"] || [filecategoryUp isEqualToString:@"WMA"] || [filecategoryUp isEqualToString:@"MID"] || [filecategoryUp isEqualToString:@"RM"] || [filecategoryUp isEqualToString:@"3GP"] || [filecategoryUp isEqualToString:@"MP4"]){
            fileimg = [UIImage imageNamed:@"moivefile"];
        }else if ([filecategoryUp isEqualToString:@"TXT"]){
            fileimg = [UIImage imageNamed:@"textfile"];
        }else{
            fileimg = [UIImage imageNamed:@"not"];
        }
    }
    return fileimg;
}

@end


